<?php

/**
*	模糊查询数据库
*
*/


//包含公共文件
// include 'D:/mybbs_1702/common/common.php';
include './head.php';


//接收get 传值
// var_dump($_GET);
$content = $_GET['content'];
// var_dump($content);

//判断字符长度
if (strlen($content) > 60 ) {

	exit('<>查询的字符,超出指定长度,请重新输入');
}

//模糊查询(标题,或内容中含搜索的关键字) , 并分页
$resFind = myPage($link ,  4 , 'id' , DB_TABLE_DETAIL , "where isdel=0 and rate=0  and   content like '%$content%' or title like '%$content%'  order by addtime desc");
// var_dump($resFind);

//判断是否分页,模糊查询成功
if (!$resFind) {

	// exit('您查找的内容不存在,请重新输入');
	$content    = '您查找的内容不存在,请重新输入';
	$targetFile = $webSite . 'index.php';
	include './tip.php';
	die;
}


//获取当前页数
$currPage = isset($_GET['page'])?$_GET['page']:1;

//遍历出所有版块信息
$resPub = mySelect($link, '*' , DB_TABLE_CG);
//var_dump($resPub);

//遍历出所有的用户信息
$resAuthor = mySelect($link , '*' , DB_TABLE_USER); 
//var_dump($resPubUser);


//获取当天凌晨的时间戳
//var_dump(date('Y-m-d H:i:s'));
$zeroTime = (strtotime(date('Y-m-d') , time()));
// $zeroTime2 = date('Y-m-d H:i:s' , $zeroTime);
// var_dump($zeroTime);
// var_dump($zeroTime2);

//计算当日发表的帖子条数
$todayCount = myCount($link , 'id' , DB_TABLE_DETAIL , "where first = 1    and    addtime > $zeroTime "); 
// var_dump($todayCount);


//遍历等级表
$resLevel = mySelect($link , '*' , DB_TABLE_LEVEL); 
//var_dump($resLevel);

//拆开分页数组
if ($resFind) {

	extract($resFind);
	$resDetail = $rows;
}

//判断当前页面是否超出范围
if ($currPage > $total) {
	$currPage = $total;
}
if ($currPage < 1) {
	$currPage = 1;
}

// var_dump($resDetail);
// var_dump($prev);
// var_dump($next);
// var_dump($total);
//  var_dump($offset);
// var_dump($num);

//打包数组
$arr = compact('webSite', 'docRoot'  ,'resFind' ,  'resPub' , 'resGet' , 'resLevel' ,'resAuthor' ,'currPage' , 'resDetail' ,'count','total', 'num' , 'offset' ,'prev' ,'next' , 'todayCount' , 'content');
display('find.html' , $arr);